package cn.iocoder.yudao.framework.excel.core.handler;

import com.alibaba.excel.write.handler.RowWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
import org.apache.poi.ss.usermodel.Row;

public class CustomRowHeightHandler implements RowWriteHandler {

    private final float defaultHeight;

    public CustomRowHeightHandler(float defaultHeight) {
        this.defaultHeight = defaultHeight;
    }

    @Override
    public void afterRowCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Integer rowIndex, Boolean isHead) {
        if (isHead) {
            row.setHeightInPoints(20); // 设置表头行的高度
        } else {
            row.setHeightInPoints(defaultHeight); // 设置数据行的高度
        }
    }

    @Override
    public void afterRowDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Integer rowIndex, Boolean isHead) {
        // 在行处理后可以进行的操作（通常不需要在这里处理）
    }
}
